package de.Ox539.nagroid;

public class SuppressHelper {
	private int suppressCounter = 0;
	
	public boolean shouldSuppress(boolean lastOk, boolean currentlyOk, int suppressLimit) {
		if(suppressLimit == 0) {
			// Suppress spurious failures feature deactivated.
			reset();
			return false;
		}
		
		if(currentlyOk)
			return false;

		if(lastOk && !currentlyOk) {
			// Switching from good to bad...
			suppressCounter = 1;
			return true;
		}
		
		if(suppressCounter > 0 && suppressCounter < suppressLimit) {
			++suppressCounter;
			return true;
		}
		
		suppressCounter = 0;
		return false;
	}
	
	void reset() {
		suppressCounter = 0;
	}
}
